package com.itheima.config;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

public class ClassCondition implements Condition {

    /*
    根据是否有redistemplate来决定boolean值
     */
    @Override
    public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {
        boolean flag=true;
        try {
            Class.forName("org.springframework.data.redis.core.RedisTemplate");
        }catch (Exception e){
            e.printStackTrace();
            flag=false;
        }
        return flag;
    }
}
